<template>
    <div class="layout" style="padding:10px" >
        <Layout>
            
                <Breadcrumb>
                <BreadcrumbItem to="/">首页</BreadcrumbItem>
                <BreadcrumbItem to="/components/breadcrumb">角色管理</BreadcrumbItem>
                <BreadcrumbItem>新增</BreadcrumbItem>
            </Breadcrumb>
            
            <Content style="padding:20px">
                <Form ref="formInline" :model="sysRole"  >
                    <FormItem prop="user" label="请输入角色名称">
                        <Input type="text" v-model="sysRole.roleName" placeholder="">
                        </Input>
                    </FormItem>
                    <FormItem prop="user" label="请输入角色描述">
                        <Input type="textarea" :rows="4" v-model="sysRole.roleDesc" placeholder="">
                        </Input>
                    </FormItem>
                    
                    <FormItem>
                        <Button type="primary" icon="save" size='small' @click="save">保存</Button>
                        <Button type="primary" icon="arrow-back" size='small'  @click="back">返回</Button>
                    </FormItem>
                
                </Form>
            </Content>
        </Layout>
      
      
    </div>
</template>
<script>
export default {
  data(){
      return{
          sysRole:{
              roleId:this.$route.params.roleId,
              roleName:'',
              roleDesc:''
          }
      }
  },
  created(){
      //alert(this.$route.params.userAcctId)
      this.getRoleInfo()
  },
  methods:{
      back(){
        this.$router.push({name:'roleList'});
      },
      getRoleInfo(){
        this.$fetch('sys/roleEdit',{
            roleId:this.sysRole.roleId
        })
        .then(result=>{
            console.log('getRoleInfo',result)
            if(result.success){
                this.sysRole = result.sysRole
            }
        })
      },
      save(){
        this.$post('sys/roleSave',this.sysRole,'',false)
        .then(res=>{
            console.log(res)
            //alert(res.success);
            if(res.success){
                console.log('保存成功')
                this.$Message.info('保存成功')
                setTimeout(()=>{
                    this.$router.push({name:'roleList'});
                },1500)
                
            }
        })
        .catch(err=>{
            console.log('error',err)
        })
      },
  }

}
</script>
<style scoped>

</style>


